﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Axis.Web.Administrator.Global;
using Axis.BusinessObject.Core;
using Axis.Dao.Core;
namespace Axis.Web.Views.Accounts
{
    public partial class ucUserBar : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var IsAuthenticated = false;
            var member = new CMemberList();
            if (Session["MEMBERINFO"] != null)
            {
                member = Session["MEMBERINFO"] as CMemberList;
                IsAuthenticated = member.ID != 0;
            }
            if (IsAuthenticated)
            {
                main_user.Style.Add("display", "none");
                main_user_logged.Style.Add("display", "block");
                ltrLoggedUserName.Text = HttpUtility.HtmlEncode(member.LastName);
                imgLoggedAvatar.ImageUrl = member.Avatar;
                if (string.IsNullOrEmpty(member.Avatar))
                {
                    string inputValue = string.Format("<InputValue ID='{0}'/>", member.ID);
                    IList<CMemberList> list = new CCoreDao().GetMemberList(inputValue);
                    if (list != null && list.Count > 0)
                    {
                        CMemberList member2 = list[0];
                        imgLoggedAvatar.ImageUrl = member2.Avatar;
                    }
                }

            }
        }
    }
}